/**
 * Created by xiongxin on 17/7/26.
 */
(function(app, angular) {
    //app.directives('twToggle', function() {
    //        return {
    //            restrict: 'A',
    //            scope: true,
    //            controller: function($scope) {
    //                $scope.folded = false;
    //                $scope.toggle = function() {
    //                    $scope.folded = !$scope.folded;
    //                };
    //            }
    //        };
    //    });

    app.directive('pieCharts', function(){
        return {
            restrict: 'EA',
            template: '<div id="salaryFlockResultPie" ></div>',
            replace: true,
            link: function(){
                var myPieChart = echarts.init(document.getElementById('salaryFlockResultPie'));
                var option = {
                    color:['#ff6666', '#01aaef'],
                    legend: {
                        orient: 'vertical',
                        left: 'left',
                        data: [{
                            name: '报销',
                            textStyle: {
                                color: '#333',
                                fontSize: '0.12rem'
                            }
                        },
                            {
                                name: '工资',
                                textStyle: {
                                    color: '#333',
                                    fontSize: '0.12rem'
                                }
                            }
                        ]
                    },
                    series : [
                        {
                            type: 'pie',
                            radius : '85%',
                            center: ['50%', '50.5%'],
                            data:[
                                {value:12.5, name:'报销'},
                                {value:87.5, name:'工资'}
                            ],

                            itemStyle: {
                                normal: {
                                    label: {
                                        position: 'inner',
                                        formatter: '{d}%'
                                    }
                                }
                            }
                        }
                    ]
                };
                // 为echarts对象加载数据
                myPieChart.setOption(option);
            }
        }
    })
})(app, angular);